<?php

namespace App\Validate\api;

use Illuminate\Foundation\Http\FormRequest;
use App\Validate\BaseValidate;

class UserValidate extends BaseValidate
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'phone' => [
                'required',"regex:/^1[3456789][0-9]{9}$/"
            ],
            'password'=>'required|min:6|confirmed',
            'pwd'=>'required|min:6',
            'verifycode'=>'required',
            'newPassword'=>'required|min:6|confirmed',
            'oldPassword'=>'required',
        ];
    }

    public function messages()
    {
        return [
            'phone.required'=>'请输入电话号码',
            'phone.regex'=>'电话号码格式不正确',
            'phone.unique'=>'该电话号码已经注册,请直接登录',
            'password.required'=>'请输入密码',
            'pwd.required'=>'请输入密码',
            'password.min'=>'密码不能小于6位',
            'pwd.min'=>'密码不能小于6位',
            'password.confirmed'=>'两次密码不一致',
            'verifycode.required'=>'验证码不能为空',
            'newPassword.required'=>'新密码不能为空',
            'oldPassword.required'=>'旧密码不能为空',
            'newPassword.min'=>'新密码不能小于6位',
            'newPassword.confirmed'=>'两次密码不一致'
        ];
    }

    public $scenes = [
        'register' => ['phone', 'password','verifycode','password_confirmation'],
        'login' =>['phone', 'pwd'],
        'sendSms' =>['phone'],
        'changePassword' => ['oldPassword', 'newPassword'],
    ];
}
